package com.hkd.user_api.config;

import com.hkd.common.api.convert.*;
import com.hkd.common.api.enums.PaymentMethod;
import com.hkd.common.api.interceptor.IdempotentInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Autowired
    private IdempotentInterceptor idempotentInterceptor;
    @Autowired
    private AreaTypeConvert areaTypeConvert;
    @Autowired
    private BalanceSourceConvert balanceSourceConvert;
    @Autowired
    private IdentityCardTypeConvert identityCardTypeConvert;
    @Autowired
    private PointSourceConvert pointSourceConvert;
    @Autowired
    private SexConvert sexConvert;
    @Autowired
    private StatusConvert statusConvert;
    @Autowired
    private SupplierTypeConvert supplierTypeConvert;
    @Autowired
    private LocalDateTimeConvert localDateTimeConvert;
    @Autowired
    private PaymentMethodConvert paymentMethodConvert;
    @Autowired
    private OrderStatusConvert orderStatusConvert;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(idempotentInterceptor);
    }

    @Override
    public void addFormatters(FormatterRegistry registry) {
        registry.addConverter(areaTypeConvert);
        registry.addConverter(balanceSourceConvert);
        registry.addConverter(identityCardTypeConvert);
        registry.addConverter(pointSourceConvert);
        registry.addConverter(sexConvert);
        registry.addConverter(statusConvert);
        registry.addConverter(supplierTypeConvert);
        registry.addConverter(localDateTimeConvert);
        registry.addConverter(paymentMethodConvert);
        registry.addConverter(orderStatusConvert);
    }
}
